package com.shop2cn.iapi.wxcomponent.parameter;

/**
 * @ClassName :AuditEnum
 * @Author :MrCao
 * @Description : 小程序授权枚举类
 * @Date : Create in 11:13 2019/12/5
 * @Modified BY:
 */
public enum AuditEnum {

    UNAUTHORIZED(0,"unauthorized", "未授权"),

    AUTHORIZED(1,"authorized", "已授权"),

    UPDATEAUTHORIZED(2,"updateauthorized", "授权变更");

    private int code;
    private String value;
    private String message;

    AuditEnum(int code, String value, String message) {
        this.code = code;
        this.value = value;
        this.message = message;
    }

    /**
     * 通过代码获取枚举项
     *
     * @param code
     * @return
     */
    public static AuditEnum getByCode(int code) {
        for (AuditEnum auditEnum : AuditEnum.values()) {
            if (auditEnum.getCode() == code) {
                return auditEnum;
            }
        }
        return null;
    }

    /**
     * 通过代值获取枚举项
     *
     * @param value
     * @return
     */
    public static AuditEnum getByValue(String value) {
        for (AuditEnum auditEnum : AuditEnum.values()) {
            if (auditEnum.getValue().equals(value.trim())) {
                return auditEnum;
            }
        }
        return null;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
